home *** CD-ROM | disk | FTP | other *** search
- # Jedi Knight Cog Script
- #
- # 00_SINGLECAM.COG
- #
- # Multiple cameras cog.
- # These cameras are designed to be used in single player,
- # and they can be destroyed.
- #
- # [YB]
- #
- # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
-
- symbols
-
- surface ViewSwitch
- surface ScreenTrigger
-
- thing disabledCamera nolink
-
- thing camera nolink
- thing camera1 nolink
- thing camera2 nolink
- thing camera3 nolink
- thing camera4 nolink
- thing camera5 nolink
- thing camera6 nolink
- thing camera7 nolink
- thing camera8 nolink
- thing camera9 nolink
- thing camera10 nolink
-
- int numCameras
-
- flex minChangeRate=0.5
-
- int player local
- int active=0 local
- int activeCam=-1 local
- int old_camera local
- int allowChangeCam=1 local
-
- int startHealth=0.0 local
- vector startPosition local
-
- int triggerSource local
- int dummy local
-
- #sound SwitchOnSound=activate02.wav local
- sound SwitchOffSound=deactivate02.wav local
- sound camChangeSnd=beep2.wav local
-
- message startup
- message activated
- message playeraction
- message pulse
- message timer
- message trigger
-
- end
-
- # ========================================================================================
-
- code
-
- startup:
- player = GetLocalPlayerThing();
- SetWallCel(ViewSwitch, 0);
- Return;
-
- # ........................................................................................
-
- activated:
-
- // Do not allow to activate the camera with the scope on...
- if(GetCurWeapon(player) == 13) Return;
-
- if(active) Return;
-
- active = 1;
-
- SetActorFlags(player, 0x80800000);
-
- StopThing(player);
- SetActionCog(GetSelfCog(), 0x7FFFFFFF);
-
- startHealth = GetThingHealth(player);
- startPosition = GetThingPos(player);
-
- SetPulse(0.5);
-
- SetWallCel(ViewSwitch, 1);
- // dummy = PlaySoundLocal(SwitchOnSound, 1.0, 0.0, 0);
-
- old_camera = GetCurrentCamera();
- SetCurrentCamera(0);
-
- call next_cam;
-
- Return;
-
- # ........................................................................................
-
- playeraction:
- if (GetParam(0) == 0.0) // Jump
- {
- if (GetParam(2) != 0.0) call prev_cam;
- ReturnEx(0.0);
- }
- else
- if (GetParam(0) == 1.0) // Crouch
- {
- if (GetParam(2) != 0.0) call next_cam;
- ReturnEx(0.0);
- }
- else
- if (GetParam(0) == 2.0) // Activated
- {
- call stop_cam;
- ReturnEx(0.0);
- }
- else
- if (GetParam(0) == 3.0) // Fire
- {
- // Allow the player to fire...
- ReturnEx(1.0);
- }
- else
- if (GetParam(0) == 4.0) // Strafe
- {
- if(GetParam(2) > 0)
- call next_cam;
- else
- call prev_cam;
-
- ReturnEx(0.0);
- }
- else
- if (GetParam(0) == 5.0) // Turn
- {
- if(GetParam(2) < 0)
- call next_cam;
- else
- call prev_cam;
-
- ReturnEx(0.0);
- }
- else
- if (GetParam(0) == 14.0) // Other Actions
- {
- if (GetParam(2) == 0.0) // Cycle Camera
- {
- if (GetCurrentCamera() == 0)
- {
- // We're in first person mode.
- }
- else
- {
- // We're in third person mode.
- }
- }
- ReturnEx(1.0);
- }
- else
- {
- ReturnEx(0.0);
- }
-
- Return;
-
- # ........................................................................................
-
- pulse:
- SetPulse(0.5);
-
- // check that the player didn't die
- if(GetThingHealth(player) < 1)
- {
- call stop_cam;
- Return;
- }
-
- // If he took damage to health stop the camera
- if(GetThingHealth(player) < startHealth)
- {
- call stop_cam;
- Return;
- }
-
- // If he changed position (blown by explosion, pushed, ...) stop the camera
- if(!VectorEqual(startPosition, GetThingPos(player)))
- {
- call stop_cam;
- Return;
- }
-
- Return;
-
- # ........................................................................................
-
- timer:
- allowChangeCam = 1;
- Return;
-
- # ........................................................................................
-
- next_cam:
- if(!allowChangeCam) Return;
-
- activeCam = activeCam + 1;
- if(activeCam >= numCameras) activeCam = 0;
- call switch_cam;
- Return;
-
- prev_cam:
- if(!allowChangeCam) Return;
-
- activeCam = activeCam - 1;
- if(activeCam < 0) activeCam = numCameras - 1;
- call switch_cam;
- Return;
-
- switch_cam:
- Print(" ");
- Print(" ");
- Print(" ");
- Print(" ");
- Print(" ");
- jkStringClear();
- jkStringConcatUNIString(365);
- jkStringConcatFormattedInt(activeCam, "%d ");
- jkStringOutput(-1, -1);
-
- dummy = PlaySoundLocal(camChangeSnd, 1.0, 0.0, 0);
-
- SetCameraFocus(0, camera[activeCam]);
- allowChangeCam = 0;
- SetTimerEx(minChangeRate, 1, 0, 0);
- Return;
-
- stop_cam:
- if(active)
- {
- SetCameraFocus(0, player);
- SetCurrentCamera(old_camera);
- }
-
- SetPulse(0);
- active = 0;
-
- SetWallCel(ViewSwitch,0);
- dummy = PlaySoundLocal(SwitchOffSound, 1.0, 0.0, 0);
-
- // Turn off control capture.
- SetActionCog(-1, 0);
-
- ClearActorFlags(player, 0x80800000);
-
- Print(" ");
- Print(" ");
- Print(" ");
- Print(" ");
- Print(" ");
-
- Return;
-
- # ........................................................................................
-
- trigger:
- triggerSource = GetSourceRef();
-
- // Handle only the cameras range
- if((triggerSource < 10023) || (triggerSource > 10033)) Return;
-
- camera[triggerSource - 10023] = disabledCamera;
-
- Return;
-
- end
-
-
-